package com.guet.niit.Admin.service;

import com.guet.niit.Admin.dao.ChargingDaolmpl;
import com.guet.niit.Admin.pojo.Charging;
import org.omg.Messaging.SyncScopeHelper;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class ChargingService {
    public ChargingService(){
    }

    //充电站添加
    public void chargingAdd() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入充电站的归属城市:");
        // Random scanner = null;
        //Random scanner = new Random();
        String city = scanner.next();

        System.out.println("请输入充电站的id:");
        Long id = scanner.nextLong();

        System.out.println("请输入代理商id:");
        Long agent_id = scanner.nextLong();

        System.out.println("请输入充电站名称:");
        String station_name = scanner.next();

        System.out.println("请输入充电站地址:");
        String address = scanner.next();

        System.out.println("请输入充电站详情:");
        String station_details = scanner.next();

        System.out.println("停车费金额：");
        Double parking_fee = scanner.nextDouble();

        System.out.println("是否有停车费（1为有，0为无）:");
        Integer have_parking_fee = scanner.nextInt();

        System.out.println("充电站是否禁用(1为启用，0为禁用)：");
        Double status = scanner.nextDouble();

        System.out.println("租金：");
        Double rent = scanner.nextDouble();



        //ChargingService service = new ChargingService();
        Charging charging = new Charging(city,id,station_name,agent_id,address,
                station_details,parking_fee,have_parking_fee,status,rent);
        charging.setCity(city);
        charging.setId(id);
        charging.setStation_name(station_name);
        charging.setAddress(address);
        charging.setAgent_id(agent_id);
        charging.setStation_details(station_details);
        charging.setParking_fee(parking_fee);
        charging.setHave_parking_fee(have_parking_fee);
        charging.setStatus(status);
        charging.setRent(rent);

        ChargingDaolmpl ca = new ChargingDaolmpl();
        boolean a = ca.chargingAdd(charging);


        //System.out.println(a);
    }

    //充电站删除
    public void chargingDelete(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要删除充电站的id:");
        Long id = scanner.nextLong();

//        Charging charging = new Charging();

        ChargingDaolmpl chargingDaolmpl = new ChargingDaolmpl();
        chargingDaolmpl.chargingDelete(id);

    }


    //充电站更改
    public void chargingModify(){
        Scanner ms = new Scanner(System.in);
        System.out.println("请输入需要修改的充电站id:");
        Long id = ms.nextLong();

        System.out.println("请输入充电站名称:");
        String station_name = ms.next();

        System.out.println("请输入充电站所在的城市:");
        String city = ms.next();

        System.out.println("请输入地址:");
        String address = ms.next();

        System.out.println("请输入代理商id:");
        Long agent_id = ms.nextLong();

        System.out.println("请输入充电站详情:");
        String station_details = ms.next();

        System.out.println("停车费金额：");
        Double parking_fee = ms.nextDouble();

        System.out.println("是否有停车费（1为有，0为无）:");
        Integer have_parking_fee = ms.nextInt();

        System.out.println("充电站是否禁用(1为启用，0为禁用)：");
        Double status = ms.nextDouble();

        System.out.println("租金：");
        Double rent = ms.nextDouble();

        //Charging dao = new Charging();
        //boolean flag = dao.modify(city,id,name);???
        Charging charging = new Charging(city,id,station_name,agent_id,address,
                station_details,parking_fee,have_parking_fee,status,rent);

        charging.setCity(city);
        charging.setId(id);
        charging.setStation_name(station_name);
        charging.setAddress(address);
        charging.setAgent_id(agent_id);
        charging.setStation_details(station_details);
        charging.setParking_fee(parking_fee);
        charging.setHave_parking_fee(have_parking_fee);
        charging.setStatus(status);
        charging.setRent(rent);

        ChargingDaolmpl chargingDaolmpl = new ChargingDaolmpl();
//        chargingDaolmpl.chargingModify(id,city,station_name,address,agent_id,
//                station_details,parking_fee,have_parking_fee,status,rent);

        System.out.println("充电站修改完成");
    }

    //充电站查询
    public static void chargingInquire() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你需要查询的ID:");
        Long id = scanner.nextLong();
        ChargingDaolmpl chargingDaolmpl = new ChargingDaolmpl();
        List<Charging> chargingArrayList = chargingDaolmpl.chargingInquire();
        System.out.println(chargingArrayList);
        }



}
